package com.hqd.jjvm.jnative.misc;

import com.hqd.jjvm.jnative.JNativeRegistry;
import com.hqd.jjvm.rtda.JThread;
import com.hqd.jjvm.rtda.LocalVars;

public class JSignalNativeRegistry extends JNativeRegistry {
    private static final JSignalNativeRegistry instance = new JSignalNativeRegistry();
    protected static final String CLASS_PATH = "sun/misc/Signal";

    static {
        registry(CLASS_PATH, "findSignal", "(Ljava/lang/String;)I", JSignalNativeRegistry::findSignal);
        registry(CLASS_PATH, "handle0", "(IJ)J", JSignalNativeRegistry::handle0);

    }

    private static void handle0(JThread jThread) {
        LocalVars vars = jThread.getJvmStack().getTop().getLocalVars();
        jThread.getJvmStack().pushOperandStackLongVal(0L);
    }

    private static void findSignal(JThread jThread) {
        //TODO
        jThread.getJvmStack().pushOperandStackRefVal(jThread.getJvmStack().getLocalVarsRefVal(0));
        jThread.getJvmStack().pushOperandStackIntVal(0);
    }

    public static JSignalNativeRegistry getInstance() {
        return instance;
    }
}
